package com.woniuxy.ssm.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.util.Date;

/**
 * @author linke
 * @version 1.0
 * @className: Role
 * @description: 数据校验测试类
 * @date 2021/11/20 0:10
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Role {
    @NotEmpty(message = "姓名不能为空")
    private String name;
    @Max(value = 150,message = "最大不能超过150岁")
    @Min(0)
    private Integer age;
    /**
     * 0是女，1是男
     */
    @Range(min = 0, max=1,message = "性别只有2种")
    private int sex;

    @NotBlank(message = "电话号码不能为空")
    @Pattern(regexp = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\\d{8}$",message = "电话号码格式不正确")
    private String telephone;

    @Email(message = "邮件格式不正确")
    private String email;
    @DateTimeFormat(pattern = "yyyy-MM-dd",iso = DateTimeFormat.ISO.DATE)
    @Past
    private Date birthday;

    @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss",iso = DateTimeFormat.ISO.DATE_TIME)
    private  Date createTime;
}
